<?php
namespace app\api\controller;
use app\common\BaseController;
use app\common\Net;
use app\api\model\QueryApply as QueryApplyModel;
class QueryApplyStatus extends BaseController{
    public function __construct(QueryApplyModel $queryApplyModel){
        parent::__construct();  
        $this->model = $queryApplyModel;
    }
    
    public function index(){    
        $params = $this->request->param();        
        $jsonArray=[
            "request"=>[
                "loginName"=> "LETU",
                "password"=> "Y/veTqvxj7UQ9IDCBBlqdA==",
                "settleNo"=> $params['settleNo']
            ]
        ];

        $json = json_encode($jsonArray,JSON_UNESCAPED_UNICODE);
        
        $en_param = [
            'mode' => "1",
            'content' => $json,
            'key'=>"auvY+v+HjNMmlvrR+k6CMD=="
        ]; 
        $en_res = Net::http("http://cw.tsletu.com:9999/letu/api",$en_param,'POST');
        
        $res = Net::http("https://sxthd.cpic.com.cn/sxthd/cpic/queryApplyStatus ",$en_res,'POST');
        $de_param = [
            'mode' => "0",
            'content' => $res,
            'key'=>"auvY+v+HjNMmlvrR+k6CMD=="
        ]; 
        $de_res = Net::http("http://cw.tsletu.com:9999/letu/api",$de_param,'POST');
        $obj = json_decode($de_res,true);
        $data=$obj['response'];
        if($data['returnNumber']=="0000000000"){
            $param=[                
                "stat" => $data['stat']
            ];
            $this->model->allowField(true)->save($param,['settleNo'=>$params['settleNo']]);
            
        }
        var_dump($data);      
    }

}
